﻿import com.dmotiko.general.*

class com.dmotiko.general.ButtonClip
extends com.dmotiko.general.BaseClip {
	
	public static var NORMAL:String = "buttonclip_normal";
	public static var OVER:String = "buttonclip_over";
	private var bActive:Boolean;
	
	private function initClip() {
		this.stop();
		this.useHandCursor = true;
		bActive = false;
	}
	
	public function getActive():Boolean {
		return bActive;
		
	}
	
	public function setActive(b:Boolean, noEvent:Boolean):Void {
		
		if ( b != bActive ) {
			this.bActive = b;	
			if(!noEvent) this.dispatchEvent( { type: BaseClipEvent.CHANGED, target: this, data: this.data, description: "setActive" } );
			this.onRollOut();
		}
		
	}
	
	public function onRollOver():Void {
		this.gotoAndPlay( OVER );
	}
	public function onRollOut():Void {
		
		if ( bActive ) return;
		this.gotoAndPlay( NORMAL );
	}
	public function onRelease():Void {
		this.setActive( true );
	}
	
}